﻿using Microsoft.AspNetCore.Mvc;
using ProsonUser.DomainTK;
using ProsonUser.TKDTO;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Repositories;

namespace ProsonUser.ProsonTK
{
    public class PTK : ApplicationService, ITK
    {
        private readonly IRepository<TK, int> _TK;
        public PTK(IRepository<TK, int> question)
        {
            _TK = question;

        }
        [HttpPost,Route("CreateTK")]
        public async Task<int> CreateTK(TKCreateDTO dto)
        {
            var query = await _TK.InsertAsync(ObjectMapper.Map<TKCreateDTO, TK>(dto));
            return 1;
        }
       
        [HttpGet, Route("ListTK")]
        public async Task<List<TKDTOs>> Theorderlist()
        {
            var query = await _TK.ToListAsync();
            return ObjectMapper.Map<List<TK>, List<TKDTOs>>(query);
        }
        [HttpGet, Route("FindTK")]
        public async Task<TK> Theorderlist(int id)
        {
            TK tK = await _TK.FindAsync(id);
            return tK;
        }


    }
}
